import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DataQuery, DataPageResult, DataForm } from './types';


/**
 * 获取分页数据
 *
 * @param queryParams
 */
export function getDataPage(
    queryParams?: DataQuery
  ): AxiosPromise<DataPageResult> {
    return request({
      url: '/api/dangwei',
      method: 'get',
      params: queryParams
    });
  }

  
/**
 * 获取数据详情
 *
 * @param id
 */
export function getDataForm(id: number): AxiosPromise<DataForm> {
    return request({
      url: '/api/dangwei/' + id,
      method: 'get'
    });
  }
  
  /**
   * 添加
   *
   * @param data
   */
  export function addData(data: DataForm) {
    return request({
      url: '/api/dangwei',
      method: 'post',
      data: data
    });
  }
  
  /**
   * 更新
   *
   * @param id
   * @param data
   */
  export function updateData(id: number, data: DataForm) {
    return request({
      url: '/api/dangwei/' + id,
      method: 'put',
      data: data
    });
  }
  
  /**
   * 批量删除数据，多个以英文逗号(,)分割
   *
   * @param ids
   */
  export function deleteData(ids: string) {
    return request({
      url: '/api/dangwei',
      method: 'delete',
      params: {id:ids}
    });
  }

/**
 * 获取党支部下拉树形列表
 */
export function listDzbOptions(): AxiosPromise<OptionType[]> {
  return request({
    url: '/api/dzb/options',
    method: 'get'
  });
}